package cn.gcjxsc.payment.messaging.source;

import cn.gcjxsc.common.data.notify.order.ResultHandleData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.annotation.Output;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.support.MessageBuilder;

/**
 * @author pumbaa
 * @since 1.0
 */
@EnableBinding(PaymentHandleSource.Source.class)
public class PaymentHandleSource {
    @Autowired
    private Source source;

    public void sendRechargeHandleMessage(ResultHandleData data){
        source.rechargeOutput().send(MessageBuilder.withPayload(data).build());
    }

    public void sendShoppingHandleMessage(ResultHandleData data){
        source.shoppingOutput().send(MessageBuilder.withPayload(data).build());
    }

    public interface Source {
        String RECHARGE_QUEUE_NAME = "machine_payment_recharge_order_output";
        String SHOPPING_QUEUE_NAME = "machine_payment_shopping_order_output";

        @Output(RECHARGE_QUEUE_NAME)
        MessageChannel rechargeOutput();

        @Output(SHOPPING_QUEUE_NAME)
        MessageChannel shoppingOutput();
    }
}
